package com.itheima.advantagesup.controller;


import com.itheima.advantagesup.common.R;
import com.itheima.advantagesup.service.YddArticleService;
import com.itheima.advantagesup.vo.ArticleVO;
import com.itheima.advantagesup.vo.YddArticlePageBeanVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@RestController
@RequestMapping("/ydd_article")
public class YddArticleController {
    @Autowired
    private YddArticleService yddArticleService;

    @GetMapping("/list")
    public R list(Long start_time,Long end_time, String title,Integer cateid,Integer page, Integer limit){
        log.info("分页查询");
        YddArticlePageBeanVO yddArticlePageBeanVO = yddArticleService.list(start_time,end_time,title,cateid,page,limit);
        return R.success(yddArticlePageBeanVO);
    }

    @GetMapping ("/rowInfo")
    public R getArticleById(String id){
        log.info("通过id查找文章:{}",id);
        ArticleVO articleVO = yddArticleService.getArticleById(id);
        return R.success(articleVO);
    }

    @GetMapping("/del")
    public R delete(String id){
        log.info("通过id删除文章:{}",id);
        yddArticleService.delete(id);
        return R.success();
    }

}
